#
# Copyright 2019 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

load("@com_google_protobuf//bazel:java_proto_library.bzl", "java_proto_library")
load("@com_google_protobuf//bazel:proto_library.bzl", "proto_library")
load("@rules_cc//cc:cc_library.bzl", "cc_library")
load("@rules_cc//cc:cc_test.bzl", "cc_test")

package(default_visibility = ["//visibility:public"])

cc_library(
    name = "util",
    srcs = ["util.cc"],
    hdrs = ["util.h"],
    deps = [
        "//zetasql/base:status",
        "//zetasql/common:utf_util",
        "@com_google_absl//absl/base:core_headers",
        "@com_google_absl//absl/numeric:int128",
        "@com_google_absl//absl/status",
        "@com_google_absl//absl/strings",
    ],
)

cc_test(
    name = "util_test",
    size = "small",
    srcs = ["util_test.cc"],
    deps = [
        ":util",
        "//zetasql/base:status",
        "//zetasql/base/testing:status_matchers",
        "//zetasql/base/testing:zetasql_gtest_main",
        "@com_google_absl//absl/status",
    ],
)

cc_library(
    name = "convert_internal",
    hdrs = ["convert_internal.h"],
    deps = ["//zetasql/base"],
)

cc_test(
    name = "convert_internal_test",
    size = "small",
    srcs = ["convert_internal_test.cc"],
    deps = [
        ":convert_internal",
        "//zetasql/base/testing:zetasql_gtest_main",
    ],
)

cc_library(
    name = "compression",
    srcs = ["compression.cc"],
    hdrs = ["compression.h"],
    deps = [
        "//zetasql/base:check",
        "//zetasql/base:status",
        "//zetasql/common:utf_util",
        "@com_google_absl//absl/memory",
        "@com_google_absl//absl/status",
        "@com_google_absl//absl/status:statusor",
        "@com_google_absl//absl/strings",
        "@com_google_absl//absl/strings:string_view",
    ],
)

cc_test(
    name = "compression_test",
    size = "small",
    srcs = ["compression_test.cc"],
    deps = [
        ":compression",
        "//zetasql/base/testing:status_matchers",
        "//zetasql/base/testing:zetasql_gtest_main",
        "@com_google_absl//absl/status",
    ],
)

cc_library(
    name = "convert",
    srcs = ["convert.cc"],
    hdrs = ["convert.h"],
    deps = [
        ":convert_internal",
        ":util",
        "//zetasql/base",
        "//zetasql/base:status",
        "//zetasql/public:numeric_value",
        "@com_google_absl//absl/base:core_headers",
        "@com_google_absl//absl/status:statusor",
        "@com_google_absl//absl/strings",
    ],
)

cc_test(
    name = "convert_test",
    size = "small",
    srcs = ["convert_test.cc"],
    deps = [
        ":convert",
        "//zetasql/base:status",
        "//zetasql/base/testing:status_matchers",
        "//zetasql/base/testing:zetasql_gtest_main",
        "//zetasql/compliance:functions_testlib",
        "//zetasql/public:numeric_value",
        "//zetasql/public:type_cc_proto",
        "//zetasql/public:value",
        "//zetasql/testing:test_function",
        "@com_google_absl//absl/status",
        "@com_google_absl//absl/strings",
    ],
)

cc_library(
    name = "convert_proto",
    srcs = ["convert_proto.cc"],
    hdrs = ["convert_proto.h"],
    deps = [
        "//zetasql/base:source_location",
        "//zetasql/base:status",
        "@com_google_absl//absl/strings",
        "@com_google_absl//absl/strings:cord",
        "@com_google_protobuf//:protobuf",
    ],
)

cc_test(
    name = "convert_proto_test",
    size = "small",
    srcs = ["convert_proto_test.cc"],
    deps = [
        ":convert_proto",
        "//zetasql/base/testing:status_matchers",
        "//zetasql/base/testing:zetasql_gtest_main",
        "//zetasql/testdata:test_schema_cc_proto",
    ],
)

cc_library(
    name = "convert_string",
    srcs = ["convert_string.cc"],
    hdrs = ["convert_string.h"],
    deps = [
        ":util",
        "//zetasql/base:case",
        "//zetasql/base:status",
        "//zetasql/common:string_util",
        "//zetasql/public:numeric_value",
        "@com_google_absl//absl/base:core_headers",
        "@com_google_absl//absl/status:statusor",
        "@com_google_absl//absl/strings",
    ],
)

cc_test(
    name = "convert_string_test",
    size = "small",
    srcs = ["convert_string_test.cc"],
    deps = [
        ":convert_string",
        "//zetasql/base:status",
        "//zetasql/base/testing:status_matchers",
        "//zetasql/base/testing:zetasql_gtest_main",
        "//zetasql/compliance:functions_testlib",
        "//zetasql/public:type_cc_proto",
        "//zetasql/public:value",
        "//zetasql/testing:test_function",
        "@com_google_absl//absl/status",
        "@com_google_absl//absl/strings",
    ],
)

cc_library(
    name = "convert_string_with_format",
    srcs = ["convert_string_with_format.cc"],
    hdrs = ["convert_string_with_format.h"],
    deps = [
        ":convert",
        ":format_max_output_width",
        ":string_format",
        ":util",
        "//zetasql/base:status",
        "//zetasql/public:value",
        "@com_google_absl//absl/container:flat_hash_map",
        "@com_google_absl//absl/container:flat_hash_set",
        "@com_google_absl//absl/flags:flag",
        "@com_google_absl//absl/status",
        "@com_google_absl//absl/strings",
        "@com_googlesource_code_re2//:re2",
    ],
)

cc_test(
    name = "convert_string_with_format_test",
    size = "small",
    srcs = ["convert_string_with_format_test.cc"],
    deps = [
        ":convert_string",
        ":convert_string_with_format",
        ":format_max_output_width",
        "//zetasql/base:status",
        "//zetasql/base/testing:status_matchers",
        "//zetasql/base/testing:zetasql_gtest_main",
        "//zetasql/compliance:functions_testlib",
        "//zetasql/public:numeric_value",
        "//zetasql/public:options_cc_proto",
        "//zetasql/public:type_cc_proto",
        "//zetasql/public:value",
        "//zetasql/testing:test_function",
        "@com_google_absl//absl/flags:flag",
        "@com_google_absl//absl/strings",
    ],
)

cc_library(
    name = "format_max_output_width",
    srcs = ["format_max_output_width.cc"],
    hdrs = ["format_max_output_width.h"],
    deps = [
        "@com_google_absl//absl/flags:flag",
    ],
)

cc_library(
    name = "input_format_string_max_width",
    srcs = ["input_format_string_max_width.cc"],
    hdrs = ["input_format_string_max_width.h"],
    deps = ["@com_google_absl//absl/flags:flag"],
)

cc_library(
    name = "string_format",
    srcs = ["string_format.cc"],
    hdrs = ["string_format.h"],
    deps = [
        ":convert_proto",
        ":format_max_output_width",
        "//zetasql/base",
        "//zetasql/base:ret_check",
        "//zetasql/base:status",
        "//zetasql/common:utf_util",
        "//zetasql/public:json_value",
        "//zetasql/public:numeric_value",
        "//zetasql/public:options_cc_proto",
        "//zetasql/public:strings",
        "//zetasql/public:type",
        "//zetasql/public:type_cc_proto",
        "//zetasql/public:value",
        "//zetasql/public/types",
        "@com_google_absl//absl/base:core_headers",
        "@com_google_absl//absl/flags:flag",
        "@com_google_absl//absl/status",
        "@com_google_absl//absl/strings",
        "@com_google_absl//absl/strings:cord",
        "@com_google_absl//absl/strings:str_format",
        "@com_google_absl//absl/types:span",
        "@com_google_protobuf//:protobuf",
        "@com_googlesource_code_re2//:re2",
        "@icu//icu4c/source/common:headers",
    ],
)

cc_test(
    name = "format_test",
    size = "medium",
    srcs = ["format_test.cc"],
    shard_count = 6,
    deps = [
        ":format_max_output_width",
        ":string_format",
        "//zetasql/base",
        "//zetasql/base:map_util",
        "//zetasql/base:status",
        "//zetasql/base/testing:status_matchers",
        "//zetasql/base/testing:zetasql_gtest_main",
        "//zetasql/compliance:functions_testlib",
        "//zetasql/public:civil_time",
        "//zetasql/public:value",
        "//zetasql/public/types",
        "//zetasql/testdata:test_schema_cc_proto",
        "//zetasql/testing:test_function",
        "//zetasql/testing:test_value",
        "@com_google_absl//absl/base",
        "@com_google_absl//absl/cleanup",
        "@com_google_absl//absl/flags:flag",
        "@com_google_absl//absl/functional:bind_front",
        "@com_google_absl//absl/random",
        "@com_google_absl//absl/status",
        "@com_google_absl//absl/status:statusor",
        "@com_google_absl//absl/strings",
        "@com_google_absl//absl/types:span",
    ],
)

cc_test(
    name = "string_format_test",
    size = "small",
    srcs = ["string_format_test.cc"],
    deps = [
        ":string_format",
        "//zetasql/base",
        "//zetasql/base/testing:status_matchers",
        "//zetasql/base/testing:zetasql_gtest_main",
        "//zetasql/common/testing:testing_proto_util",
        "//zetasql/public:options_cc_proto",
        "//zetasql/public:value",
        "//zetasql/public/types",
        "//zetasql/testdata:test_schema_cc_proto",
        "@com_google_absl//absl/status",
        "@com_google_absl//absl/strings",
        "@com_google_absl//absl/types:span",
    ],
)

cc_library(
    name = "arithmetics_internal",
    hdrs = ["arithmetics_internal.h"],
    deps = [
        "//zetasql/base",
    ],
)

cc_test(
    name = "arithmetics_internal_test",
    size = "small",
    srcs = ["arithmetics_internal_test.cc"],
    deps = [
        ":arithmetics_internal",
        "//zetasql/base/testing:zetasql_gtest_main",
    ],
)

cc_library(
    name = "arithmetics",
    hdrs = ["arithmetics.h"],
    deps = [
        ":arithmetics_internal",
        ":convert",
        ":util",
        "//zetasql/base:status",
        "//zetasql/public:numeric_value",
        "@com_google_absl//absl/base:core_headers",
        "@com_google_absl//absl/status:statusor",
        "@com_google_absl//absl/strings",
    ],
)

cc_test(
    name = "arithmetics_test",
    size = "small",
    srcs = ["arithmetics_test.cc"],
    deps = [
        ":arithmetics",
        "//zetasql/base",
        "//zetasql/base:status",
        "//zetasql/base/testing:status_matchers",
        "//zetasql/base/testing:zetasql_gtest_main",
        "//zetasql/compliance:functions_testlib",
        "//zetasql/public:options_cc_proto",
        "//zetasql/public:type",
        "//zetasql/public:type_cc_proto",
        "//zetasql/public:value",
        "//zetasql/testing:test_function",
        "@com_google_absl//absl/numeric:int128",
        "@com_google_absl//absl/status",
    ],
)

cc_library(
    name = "bitwise",
    srcs = ["bitwise.cc"],
    hdrs = ["bitwise.h"],
    deps = [
        ":bitwise_agg_mode_cc_proto",
        ":util",
        "//zetasql/base:bits",
        "//zetasql/base:status",
        "@com_google_absl//absl/base",
        "@com_google_absl//absl/base:core_headers",
        "@com_google_absl//absl/strings",
    ],
)

cc_test(
    name = "bitwise_test",
    size = "small",
    srcs = ["bitwise_test.cc"],
    deps = [
        ":bitwise",
        ":bitwise_agg_mode_cc_proto",
        "//zetasql/base",
        "//zetasql/base:status",
        "//zetasql/base/testing:zetasql_gtest_main",
        "//zetasql/compliance:functions_testlib",
        "//zetasql/public:type_cc_proto",
        "//zetasql/public:value",
        "//zetasql/testing:test_function",
    ],
)

cc_library(
    name = "bitcast",
    hdrs = ["bitcast.h"],
    deps = [
        "//zetasql/base:status",
        "@com_google_absl//absl/base",
    ],
)

cc_test(
    name = "bitcast_test",
    size = "small",
    srcs = ["bitcast_test.cc"],
    deps = [
        ":bitcast",
        "//zetasql/base:status",
        "//zetasql/base/testing:zetasql_gtest_main",
    ],
)

cc_library(
    name = "comparison",
    hdrs = ["comparison.h"],
)

cc_test(
    name = "comparison_test",
    size = "small",
    srcs = ["comparison_test.cc"],
    deps = [
        ":comparison",
        "//zetasql/base/testing:zetasql_gtest_main",
    ],
)

cc_library(
    name = "date_time_util_internal",
    srcs = ["date_time_util_internal.cc"],
    hdrs = ["date_time_util_internal.h"],
    deps = [
        "//zetasql/base",
        "@com_google_absl//absl/time",
    ],
)

cc_test(
    name = "date_time_util_internal_test",
    size = "small",
    srcs = ["date_time_util_internal_test.cc"],
    deps = [
        ":date_time_util_internal",
        "//zetasql/base/testing:zetasql_gtest_main",
        "@com_google_absl//absl/time",
    ],
)

cc_library(
    name = "date_time_util",
    srcs = ["date_time_util.cc"],
    hdrs = ["date_time_util.h"],
    deps = [
        ":arithmetics",
        ":date_time_util_internal",
        ":datetime_cc_proto",
        "//zetasql/base",
        "//zetasql/base:mathutil",
        "//zetasql/base:ret_check",
        "//zetasql/base:status",
        "//zetasql/base:time_proto_util",
        "//zetasql/common:errors",
        "//zetasql/public:civil_time",
        "//zetasql/public:interval_value",
        "//zetasql/public:pico_time",
        "//zetasql/public:time_zone_util",
        "//zetasql/public/proto:type_annotation_cc_proto",
        "//zetasql/public/types:timestamp_util",
        "@com_google_absl//absl/base:core_headers",
        "@com_google_absl//absl/base:no_destructor",
        "@com_google_absl//absl/container:flat_hash_map",
        "@com_google_absl//absl/numeric:int128",
        "@com_google_absl//absl/status",
        "@com_google_absl//absl/status:statusor",
        "@com_google_absl//absl/strings",
        "@com_google_absl//absl/strings:str_format",
        "@com_google_absl//absl/time",
        "@com_google_googleapis//google/type:date_cc_proto",
        "@com_google_protobuf//:protobuf",
    ],
)

cc_library(
    name = "parse_date_time_utils",
    srcs = ["parse_date_time_utils.cc"],
    hdrs = ["parse_date_time_utils.h"],
    deps = [
        ":date_time_util",
        "@com_google_absl//absl/base:core_headers",
        "@com_google_absl//absl/time",
    ],
)

cc_library(
    name = "parse_date_time",
    srcs = ["parse_date_time.cc"],
    hdrs = ["parse_date_time.h"],
    deps = [
        ":date_time_util",
        ":date_time_util_internal",
        ":datetime_cc_proto",
        ":parse_date_time_utils",
        "//zetasql/base",
        "//zetasql/base:ret_check",
        "//zetasql/base:status",
        "//zetasql/common:errors",
        "//zetasql/public:civil_time",
        "//zetasql/public:pico_time",
        "//zetasql/public:strings",
        "//zetasql/public/types:timestamp_util",
        "@com_google_absl//absl/base:nullability",
        "@com_google_absl//absl/status",
        "@com_google_absl//absl/strings",
        "@com_google_absl//absl/strings:str_format",
        "@com_google_absl//absl/time",
    ],
)

cc_library(
    name = "cast_date_time",
    srcs = ["cast_date_time.cc"],
    hdrs = ["cast_date_time.h"],
    deps = [
        ":date_time_util",
        ":datetime_cc_proto",
        ":input_format_string_max_width",
        ":parse_date_time_utils",
        "//zetasql/base",
        "//zetasql/base:general_trie",
        "//zetasql/base:map_util",
        "//zetasql/base:mathutil",
        "//zetasql/base:ret_check",
        "//zetasql/base:status",
        "//zetasql/common:errors",
        "//zetasql/common:utf_util",
        "//zetasql/public:civil_time",
        "//zetasql/public:pico_time",
        "//zetasql/public:strings",
        "//zetasql/public:type",
        "//zetasql/public:type_cc_proto",
        "@com_google_absl//absl/base:core_headers",
        "@com_google_absl//absl/container:flat_hash_map",
        "@com_google_absl//absl/flags:flag",
        "@com_google_absl//absl/status",
        "@com_google_absl//absl/status:statusor",
        "@com_google_absl//absl/strings",
        "@com_google_absl//absl/strings:str_format",
        "@com_google_absl//absl/time",
        "@com_google_absl//absl/types:span",
        "@icu//icu4c/source/common:headers",
    ],
)

cc_library(
    name = "math",
    srcs = ["math.cc"],
    hdrs = ["math.h"],
    deps = [
        ":arithmetics",
        ":rounding_mode_cc_proto",
        ":util",
        "//zetasql/base:status",
        "//zetasql/common:multiprecision_int",
        "//zetasql/public:numeric_value",
        "@com_google_absl//absl/base:core_headers",
        "@com_google_absl//absl/status",
        "@com_google_absl//absl/status:statusor",
        "@com_google_absl//absl/strings",
        "@com_google_absl//absl/strings:str_format",
    ],
)

cc_test(
    name = "math_test",
    size = "small",
    srcs = ["math_test.cc"],
    deps = [
        ":math",
        ":rounding_mode_cc_proto",
        "//zetasql/base",
        "//zetasql/base:status",
        "//zetasql/base/testing:status_matchers",
        "//zetasql/base/testing:zetasql_gtest_main",
        "//zetasql/common:float_margin",
        "//zetasql/compliance:functions_testlib",
        "//zetasql/public:numeric_value",
        "//zetasql/public:type",
        "//zetasql/public:type_cc_proto",
        "//zetasql/public:value",
        "//zetasql/testing:test_function",
        "@com_google_absl//absl/status",
        "@com_google_absl//absl/strings",
    ],
)

cc_library(
    name = "net",
    srcs = ["net.cc"],
    hdrs = ["net.h"],
    deps = [
        ":util",
        "//zetasql/base:status",
        "//zetasql/base/net:idn",
        "//zetasql/base/net:ipaddress",
        "//zetasql/base/net:public_suffix",
        "@com_google_absl//absl/base:core_headers",
        "@com_google_absl//absl/functional:function_ref",
        "@com_google_absl//absl/status",
        "@com_google_absl//absl/strings",
    ],
)

cc_test(
    name = "net_test",
    size = "small",
    srcs = ["net_test.cc"],
    deps = [
        ":net",
        "//zetasql/base:status",
        "//zetasql/base/testing:status_matchers",
        "//zetasql/base/testing:zetasql_gtest_main",
        "//zetasql/compliance:functions_testlib",
        "//zetasql/public:type",
        "//zetasql/public:value",
        "//zetasql/testing:test_function",
        "@com_google_absl//absl/status",
        "@com_google_absl//absl/strings:string_view",
        "@com_googlesource_code_re2//:re2",
    ],
)

cc_library(
    name = "numeric",
    srcs = ["numeric.cc"],
    hdrs = ["numeric.h"],
    deps = [
        ":util",
        "//zetasql/base",
        "//zetasql/public:numeric_value",
        "@com_google_absl//absl/status",
        "@com_google_absl//absl/strings",
    ],
)

cc_test(
    name = "numeric_test",
    size = "small",
    srcs = ["numeric_test.cc"],
    deps = [
        ":numeric",
        "//zetasql/base/testing:status_matchers",
        "//zetasql/base/testing:zetasql_gtest_main",
        "//zetasql/compliance:functions_testlib",
        "//zetasql/public:numeric_value",
        "//zetasql/public:value",
        "//zetasql/testing:test_function",
        "@com_google_absl//absl/status",
    ],
)

cc_library(
    name = "string",
    srcs = ["string.cc"],
    hdrs = ["string.h"],
    deps = [
        ":normalize_mode_cc_proto",
        ":util",
        "//zetasql/base",
        "//zetasql/base:check",
        "//zetasql/base:map_util",
        "//zetasql/base:status",
        "//zetasql/base:stl_util",
        "//zetasql/base:strings",
        "//zetasql/common:utf_util",
        "//zetasql/public:strings",
        "@com_google_absl//absl/algorithm:container",
        "@com_google_absl//absl/base",
        "@com_google_absl//absl/base:core_headers",
        "@com_google_absl//absl/base:no_destructor",
        "@com_google_absl//absl/container:flat_hash_map",
        "@com_google_absl//absl/container:flat_hash_set",
        "@com_google_absl//absl/status",
        "@com_google_absl//absl/strings",
        "@com_google_absl//absl/strings:str_format",
        "@com_google_absl//absl/types:span",
    ],
)

cc_library(
    name = "string_with_collation",
    srcs = ["string_with_collation.cc"],
    hdrs = ["string_with_collation.h"],
    deps = [
        ":like",
        ":string",
        ":util",
        "//zetasql/base:check",
        "//zetasql/base:status",
        "//zetasql/common:utf_util",
        "//zetasql/public:collator_lite",
        "//zetasql/public:type_cc_proto",
        "@com_google_absl//absl/base:core_headers",
        "@com_google_absl//absl/memory",
        "@com_google_absl//absl/status",
        "@com_google_absl//absl/status:statusor",
        "@com_google_absl//absl/strings",
        "@com_googlesource_code_re2//:re2",
    ],
)

cc_library(
    name = "uuid",
    srcs = ["uuid.cc"],
    hdrs = ["uuid.h"],
    deps = [
        "//zetasql/base:status",
        "//zetasql/public:uuid_value",
        "@com_google_absl//absl/random",
        "@com_google_absl//absl/random:bit_gen_ref",
        "@com_google_absl//absl/random:distributions",
        "@com_google_absl//absl/strings:string_view",
    ],
)

cc_test(
    name = "uuid_test",
    size = "small",
    srcs = ["uuid_test.cc"],
    deps = [
        ":uuid",
        "//zetasql/base",
        "//zetasql/base/testing:zetasql_gtest_main",
        "@com_google_absl//absl/random",
        "@com_google_absl//absl/random:mock_distributions",
        "@com_google_absl//absl/random:mocking_bit_gen",
    ],
)

cc_test(
    name = "string_test",
    size = "small",
    srcs = ["string_test.cc"],
    deps = [
        ":normalize_mode_cc_proto",
        ":string",
        "//zetasql/base",
        "//zetasql/base/testing:status_matchers",
        "//zetasql/base/testing:zetasql_gtest_main",
        "//zetasql/compliance:functions_testlib",
        "//zetasql/public:type",
        "//zetasql/public:type_cc_proto",
        "//zetasql/public:value",
        "//zetasql/testing:test_function",
        "@com_google_absl//absl/status",
        "@com_google_absl//absl/strings",
    ],
)

cc_test(
    name = "string_with_collation_test",
    size = "small",
    srcs = ["string_with_collation_test.cc"],
    deps = [
        ":string_with_collation",
        "//zetasql/base/testing:status_matchers",
        "//zetasql/base/testing:zetasql_gtest_main",
        "//zetasql/compliance:functions_testlib",
        "//zetasql/public:collator",  # buildcleaner: keep
        "//zetasql/public:type_cc_proto",
        "//zetasql/public:value",
        "//zetasql/public/types",
        "//zetasql/testing:test_function",
        "@com_google_absl//absl/status",
        "@com_google_absl//absl/strings",
    ],
)

cc_library(
    name = "regexp",
    srcs = ["regexp.cc"],
    hdrs = ["regexp.h"],
    deps = [
        ":string",
        ":util",
        "//zetasql/base",
        "//zetasql/base:ret_check",
        "//zetasql/base:status",
        "//zetasql/base:strings",
        "//zetasql/common:utf_util",
        "//zetasql/public:options_cc_proto",
        "//zetasql/public:type_cc_proto",
        "//zetasql/public:value",
        "//zetasql/public/types",
        "@com_google_absl//absl/base:core_headers",
        "@com_google_absl//absl/container:flat_hash_set",
        "@com_google_absl//absl/memory",
        "@com_google_absl//absl/status",
        "@com_google_absl//absl/status:statusor",
        "@com_google_absl//absl/strings",
        "@com_google_absl//absl/types:span",
        "@com_googlesource_code_re2//:re2",
        "@icu//icu4c/source/common:headers",
    ],
)

cc_test(
    name = "regexp_test",
    size = "small",
    srcs = ["regexp_test.cc"],
    deps = [
        ":regexp",
        "//zetasql/base/testing:status_matchers",
        "//zetasql/base/testing:zetasql_gtest_main",
        "//zetasql/compliance:functions_testlib",
        "//zetasql/public:type",
        "//zetasql/public:type_cc_proto",
        "//zetasql/public:value",
        "//zetasql/testing:test_function",
        "@com_google_absl//absl/status",
        "@com_google_absl//absl/status:statusor",
        "@com_google_absl//absl/strings:string_view",
        "@com_googlesource_code_re2//:re2",
    ],
)

proto_library(
    name = "datetime_proto",
    srcs = ["datetime.proto"],
)

cc_proto_library(
    name = "datetime_cc_proto",
    deps = ["datetime_proto"],
)

java_proto_library(
    name = "datetime_java_proto",
    deps = [":datetime_proto"],
)

proto_library(
    name = "normalize_mode_proto",
    srcs = ["normalize_mode.proto"],
)

cc_proto_library(
    name = "normalize_mode_cc_proto",
    deps = ["normalize_mode_proto"],
)

java_proto_library(
    name = "normalize_mode_java_proto",
    deps = [":normalize_mode_proto"],
)

proto_library(
    name = "rounding_mode_proto",
    srcs = ["rounding_mode.proto"],
    deps = [
        "//zetasql/public:type_proto",
    ],
)

cc_proto_library(
    name = "rounding_mode_cc_proto",
    deps = ["rounding_mode_proto"],
)

java_proto_library(
    name = "rounding_mode_java_proto",
    deps = [":rounding_mode_proto"],
)

proto_library(
    name = "array_find_mode_proto",
    srcs = ["array_find_mode.proto"],
    deps = ["//zetasql/public:type_proto"],
)

java_proto_library(
    name = "array_find_mode_java_proto",
    deps = [":array_find_mode_proto"],
)

cc_proto_library(
    name = "array_find_mode_cc_proto",
    deps = [":array_find_mode_proto"],
)

proto_library(
    name = "bitwise_agg_mode_proto",
    srcs = ["bitwise_agg_mode.proto"],
    deps = ["//zetasql/public:type_proto"],
)

java_proto_library(
    name = "bitwise_agg_mode_java_proto",
    deps = [":bitwise_agg_mode_proto"],
)

cc_proto_library(
    name = "bitwise_agg_mode_cc_proto",
    deps = [":bitwise_agg_mode_proto"],
)

proto_library(
    name = "unsupported_fields_proto",
    srcs = ["unsupported_fields.proto"],
    deps = ["//zetasql/public:type_proto"],
)

cc_proto_library(
    name = "unsupported_fields_cc_proto",
    deps = [":unsupported_fields_proto"],
)

java_proto_library(
    name = "unsupported_fields_java_proto",
    deps = [":unsupported_fields_proto"],
)

proto_library(
    name = "differential_privacy_proto",
    srcs = ["differential_privacy.proto"],
    deps = [
        "//zetasql/proto:anon_output_with_report_proto",
        "//zetasql/public:type_proto",
    ],
)

java_proto_library(
    name = "differential_privacy_java_proto",
    deps = [":differential_privacy_proto"],
)

cc_proto_library(
    name = "differential_privacy_cc_proto",
    deps = [":differential_privacy_proto"],
)

proto_library(
    name = "array_zip_mode_proto",
    srcs = ["array_zip_mode.proto"],
    deps = ["//zetasql/public:type_proto"],
)

cc_proto_library(
    name = "array_zip_mode_cc_proto",
    deps = [":array_zip_mode_proto"],
)

java_proto_library(
    name = "array_zip_mode_java_proto",
    deps = [":array_zip_mode_proto"],
)

proto_library(
    name = "range_sessionize_mode_proto",
    srcs = ["range_sessionize_mode.proto"],
    deps = ["//zetasql/public:type_proto"],
)

java_proto_library(
    name = "range_sessionize_mode_java_proto",
    deps = [":range_sessionize_mode_proto"],
)

cc_proto_library(
    name = "range_sessionize_mode_cc_proto",
    deps = [":range_sessionize_mode_proto"],
)

cc_library(
    name = "json_internal",
    srcs = ["json_internal.cc"],
    hdrs = ["json_internal.h"],
    deps = [
        "//zetasql/base:case",
        "//zetasql/base:check",
        "//zetasql/base:status",
        "//zetasql/base:strings",
        "//zetasql/common:json_parser",
        "//zetasql/common:json_util",
        "//zetasql/common:thread_stack",
        "@com_google_absl//absl/base:core_headers",
        "@com_google_absl//absl/memory",
        "@com_google_absl//absl/status",
        "@com_google_absl//absl/status:statusor",
        "@com_google_absl//absl/strings",
        "@com_googlesource_code_re2//:re2",
    ],
)

cc_library(
    name = "json",
    srcs = ["json.cc"],
    hdrs = ["json.h"],
    deps = [
        ":convert",
        ":convert_string",
        ":json_format",
        ":json_internal",
        ":to_json",
        "//zetasql/base:lossless_convert",
        "//zetasql/base:ret_check",
        "//zetasql/base:status",
        "//zetasql/base:strings",
        "//zetasql/common:errors",
        "//zetasql/common:json_util",
        "//zetasql/public:json_value",
        "//zetasql/public:language_options",
        "//zetasql/public:numeric_value",
        "//zetasql/public:value",
        "@com_google_absl//absl/base:core_headers",
        "@com_google_absl//absl/container:btree",
        "@com_google_absl//absl/container:flat_hash_set",
        "@com_google_absl//absl/container:inlined_vector",
        "@com_google_absl//absl/functional:function_ref",
        "@com_google_absl//absl/memory",
        "@com_google_absl//absl/status",
        "@com_google_absl//absl/status:statusor",
        "@com_google_absl//absl/strings",
        "@com_google_absl//absl/types:span",
        "@com_googlesource_code_re2//:re2",
    ],
)

cc_test(
    name = "json_test",
    srcs = ["json_test.cc"],
    deps = [
        ":json",
        ":json_internal",
        "//zetasql/base",
        "//zetasql/base/testing:status_matchers",
        "//zetasql/base/testing:zetasql_gtest_main",
        "//zetasql/compliance:functions_testlib",
        "//zetasql/public:json_value",
        "//zetasql/public:language_options",
        "//zetasql/public:numeric_value",
        "//zetasql/public:options_cc_proto",
        "//zetasql/public:value",
        "//zetasql/public/types",
        "//zetasql/testing:test_function",
        "@com_google_absl//absl/status",
        "@com_google_absl//absl/status:statusor",
        "@com_google_absl//absl/strings",
        "@com_google_absl//absl/strings:str_format",
        "@com_google_absl//absl/types:span",
    ],
)

cc_library(
    name = "distance",
    srcs = ["distance.cc"],
    hdrs = ["distance.h"],
    deps = [
        ":arithmetics",
        ":math",
        "//zetasql/base:edit_distance",
        "//zetasql/base:ret_check",
        "//zetasql/base:status",
        "//zetasql/public:value",
        "//zetasql/public/types",
        "@com_google_absl//absl/container:btree",
        "@com_google_absl//absl/container:flat_hash_map",
        "@com_google_absl//absl/functional:function_ref",
        "@com_google_absl//absl/status",
        "@com_google_absl//absl/status:statusor",
        "@com_google_absl//absl/strings",
        "@com_google_absl//absl/types:span",
        "@icu//icu4c/source/common:headers",
    ],
)

cc_test(
    name = "distance_test",
    srcs = ["distance_test.cc"],
    deps = [
        ":distance",
        "//zetasql/base:check",
        "//zetasql/base/testing:status_matchers",
        "//zetasql/base/testing:zetasql_gtest_main",
        "//zetasql/public:value",
        "//zetasql/public/types",
        "@com_google_absl//absl/log",
        "@com_google_absl//absl/random",
        "@com_google_absl//absl/random:bit_gen_ref",
        "@com_google_absl//absl/random:distributions",
        "@com_google_absl//absl/status",
        "@com_google_absl//absl/strings",
        "@com_google_absl//absl/types:span",
    ],
)

cc_library(
    name = "generate_array",
    hdrs = ["generate_array.h"],
    deps = [
        ":arithmetics",
        ":date_time_util",
        ":datetime_cc_proto",
        "//zetasql/base:source_location",
        "//zetasql/base:status",
        "//zetasql/public:numeric_value",
        "//zetasql/public:pico_time",
        "@com_google_absl//absl/status",
        "@com_google_absl//absl/status:statusor",
        "@com_google_absl//absl/time",
    ],
)

cc_test(
    name = "generate_array_test",
    srcs = ["generate_array_test.cc"],
    deps = [
        ":generate_array",
        "//zetasql/base:status",
        "//zetasql/base/testing:status_matchers",
        "//zetasql/base/testing:zetasql_gtest_main",
        "//zetasql/common:float_margin",
        "//zetasql/common:internal_value",
        "//zetasql/compliance:functions_testlib",
        "//zetasql/public:numeric_value",
        "//zetasql/public:type_cc_proto",
        "//zetasql/public:value",
        "//zetasql/testing:test_function",
        "@com_google_absl//absl/strings",
    ],
)

cc_library(
    name = "common_proto",
    srcs = ["common_proto.cc"],
    hdrs = ["common_proto.h"],
    deps = [
        ":date_time_util",
        "//zetasql/base:status",
        "//zetasql/common:errors",
        "//zetasql/common:utf_util",
        "//zetasql/public:civil_time",
        "@com_google_absl//absl/status:statusor",
        "@com_google_absl//absl/strings",
        "@com_google_absl//absl/strings:cord",
        "@com_google_googleapis//google/type:latlng_cc_proto",
        "@com_google_googleapis//google/type:timeofday_cc_proto",
        "@com_google_protobuf//:protobuf",
    ],
)

cc_test(
    name = "common_proto_test",
    srcs = ["common_proto_test.cc"],
    deps = [
        ":common_proto",
        ":date_time_util",
        "//zetasql/base:status",
        "//zetasql/base/testing:status_matchers",
        "//zetasql/base/testing:zetasql_gtest_main",
        "//zetasql/public:civil_time",
        "@com_google_absl//absl/status",
        "@com_google_absl//absl/strings",
        "@com_google_absl//absl/strings:cord",
        "@com_google_googleapis//google/type:timeofday_cc_proto",
        "@com_google_protobuf//:protobuf",
    ],
)

proto_library(
    name = "rank_type_proto",
    srcs = ["rank_type.proto"],
    deps = ["//zetasql/public:type_proto"],
)

cc_proto_library(
    name = "rank_type_cc_proto",
    deps = [":rank_type_proto"],
)

java_proto_library(
    name = "rank_type_java_proto",
    deps = [":rank_type_proto"],
)

cc_library(
    name = "hash",
    srcs = ["hash.cc"],
    hdrs = ["hash.h"],
    deps = [
        "//zetasql/base",
        "//zetasql/base:check",
        "//zetasql/base:endian",
        "@boringssl//:crypto",
        "@com_google_absl//absl/base",
        "@com_google_absl//absl/base:core_headers",
        "@com_google_absl//absl/numeric:int128",
        "@com_google_absl//absl/status",
        "@com_google_absl//absl/status:statusor",
        "@com_google_absl//absl/strings",
        "@com_google_farmhash//:farmhash_fingerprint",
    ],
)

cc_test(
    name = "hash_test",
    srcs = ["hash_test.cc"],
    deps = [
        ":hash",
        "//zetasql/base/testing:zetasql_gtest_main",
        "//zetasql/compliance:functions_testlib",
        "//zetasql/public:type",
        "//zetasql/public:value",
        "//zetasql/testing:test_function",
        "@com_google_absl//absl/strings",
    ],
)

cc_library(
    name = "json_format",
    srcs = ["json_format.cc"],
    hdrs = ["json_format.h"],
    deps = [
        ":date_time_util",
        "//zetasql/base:check",
        "//zetasql/base:ret_check",
        "//zetasql/base:status",
        "//zetasql/common:errors",
        "//zetasql/common:json_util",
        "//zetasql/common:string_util",
        "//zetasql/public:civil_time",
        "//zetasql/public:interval_value",
        "//zetasql/public:json_value",
        "//zetasql/public:numeric_value",
        "//zetasql/public:options_cc_proto",
        "//zetasql/public:timestamp_picos_value",
        "//zetasql/public:type",
        "//zetasql/public:type_cc_proto",
        "//zetasql/public:uuid_value",
        "//zetasql/public:value",
        "@com_google_absl//absl/status",
        "@com_google_absl//absl/strings",
        "@com_google_absl//absl/time",
        "@com_google_protobuf//:protobuf",
    ],
)

cc_test(
    name = "json_format_test",
    srcs = ["json_format_test.cc"],
    deps = [
        ":date_time_util",
        ":json_format",
        "//zetasql/base:check",
        "//zetasql/base:map_util",
        "//zetasql/base/testing:status_matchers",
        "//zetasql/base/testing:zetasql_gtest_main",
        "//zetasql/compliance:functions_testlib",
        "//zetasql/public:json_value",
        "//zetasql/public:options_cc_proto",
        "//zetasql/public:pico_time",
        "//zetasql/public:timestamp_picos_value",
        "//zetasql/public:type",
        "//zetasql/public:value",
        "//zetasql/testing:test_function",
        "@com_google_absl//absl/status",
        "@com_google_absl//absl/strings",
        "@com_google_absl//absl/time",
    ],
)

cc_library(
    name = "to_json",
    srcs = ["to_json.cc"],
    hdrs = ["to_json.h"],
    deps = [
        ":json_format",
        ":unsupported_fields_cc_proto",
        "//zetasql/base:logging",
        "//zetasql/base:ret_check",
        "//zetasql/base:status",
        "//zetasql/common:errors",
        "//zetasql/common:thread_stack",
        "//zetasql/public:interval_value",
        "//zetasql/public:json_value",
        "//zetasql/public:language_options",
        "//zetasql/public:options_cc_proto",
        "//zetasql/public:type",
        "//zetasql/public:type_cc_proto",
        "//zetasql/public:uuid_value",
        "//zetasql/public:value",
        "//zetasql/public/types",
        "@com_google_absl//absl/status",
        "@com_google_absl//absl/status:statusor",
        "@com_google_absl//absl/strings",
        "@com_google_absl//absl/types:span",
        "@com_google_protobuf//:protobuf",
    ],
)

cc_test(
    name = "to_json_test",
    srcs = ["to_json_test.cc"],
    deps = [
        ":date_time_util",
        ":to_json",
        ":unsupported_fields_cc_proto",
        "//zetasql/base:map_util",
        "//zetasql/base/testing:status_matchers",
        "//zetasql/base/testing:zetasql_gtest_main",
        "//zetasql/common:float_margin",
        "//zetasql/common:internal_value",
        "//zetasql/compliance:functions_testlib",
        "//zetasql/public:json_value",
        "//zetasql/public:language_options",
        "//zetasql/public:options_cc_proto",
        "//zetasql/public:pico_time",
        "//zetasql/public:simple_token_list",
        "//zetasql/public:timestamp_picos_value",
        "//zetasql/public:value",
        "//zetasql/public/types",
        "//zetasql/testing:test_function",
        "//zetasql/testing:test_value",
        "@com_google_absl//absl/status",
        "@com_google_absl//absl/status:statusor",
        "@com_google_absl//absl/strings",
        "@com_google_absl//absl/time",
    ],
)

cc_library(
    name = "percentile",
    srcs = ["percentile.cc"],
    hdrs = ["percentile.h"],
    deps = [
        "//zetasql/base",
        "//zetasql/base:check",
        "//zetasql/base:mathutil",
        "//zetasql/base:ret_check",
        "//zetasql/base:status",
        "//zetasql/common:multiprecision_int",
        "//zetasql/public:collator",
        "//zetasql/public:numeric_value",
        "@com_google_absl//absl/base:core_headers",
        "@com_google_absl//absl/status",
        "@com_google_absl//absl/status:statusor",
        "@com_google_absl//absl/strings",
    ],
)

cc_test(
    name = "percentile_test",
    size = "small",
    srcs = ["percentile_test.cc"],
    deps = [
        ":percentile",
        "//zetasql/base/testing:status_matchers",
        "//zetasql/base/testing:zetasql_gtest_main",
        "//zetasql/common:string_util",
        "//zetasql/public:numeric_value",
        "@com_google_absl//absl/status",
        "@com_google_absl//absl/strings",
        "@com_google_absl//absl/types:span",
    ],
)

cc_library(
    name = "range",
    srcs = ["range.cc"],
    hdrs = ["range.h"],
    deps = [
        ":date_time_util",
        ":datetime_cc_proto",
        "//zetasql/base:case",
        "//zetasql/base:endian",
        "//zetasql/base:ret_check",
        "//zetasql/base:status",
        "//zetasql/common:errors",
        "//zetasql/public:civil_time",
        "//zetasql/public:interval_value",
        "//zetasql/public:type_cc_proto",
        "//zetasql/public:value",
        "//zetasql/public/types",
        "@com_google_absl//absl/base:core_headers",
        "@com_google_absl//absl/status",
        "@com_google_absl//absl/status:statusor",
        "@com_google_absl//absl/strings",
        "@com_google_absl//absl/strings:str_format",
        "@com_google_absl//absl/time",
    ],
)

cc_test(
    name = "range_test",
    srcs = ["range_test.cc"],
    deps = [
        ":date_time_util",
        ":range",
        "//zetasql/base:map_util",
        "//zetasql/base:status",
        "//zetasql/base/testing:status_matchers",
        "//zetasql/base/testing:zetasql_gtest_main",
        "//zetasql/compliance:functions_testlib",
        "//zetasql/public:civil_time",
        "//zetasql/public:interval_value",
        "//zetasql/public:options_cc_proto",
        "//zetasql/public:type",
        "//zetasql/public:value",
        "//zetasql/public/types",
        "//zetasql/testing:test_function",
        "//zetasql/testing:test_value",
        "@com_google_absl//absl/status",
        "@com_google_absl//absl/status:statusor",
        "@com_google_absl//absl/strings",
        "@com_google_absl//absl/strings:str_format",
        "@com_google_absl//absl/time",
    ],
)

cc_library(
    name = "like",
    srcs = ["like.cc"],
    hdrs = ["like.h"],
    deps = [
        "//zetasql/base",
        "//zetasql/base:status",
        "//zetasql/public:type_cc_proto",
        "@com_google_absl//absl/base:core_headers",
        "@com_google_absl//absl/memory",
        "@com_google_absl//absl/status:statusor",
        "@com_google_absl//absl/strings",
        "@com_googlesource_code_re2//:re2",
    ],
)

cc_test(
    name = "like_test",
    size = "small",
    srcs = ["like_test.cc"],
    deps = [
        ":like",
        "//zetasql/base:status",
        "//zetasql/base/testing:zetasql_gtest_main",
        "@com_google_absl//absl/strings",
        "@com_googlesource_code_re2//:re2",
    ],
)
